package gas.model;
/***
 * Admin is a subclass of User, essentially given all the functionality of the user,
 * with admin-specific functionality included.
 * 
 * Attributes:
 * 
 * 
 */
public class Admin extends User {
  boolean bossAdmin = false;
	public Admin(){
		super();
		bossAdmin = true;
		//Specific Admin Stuff
	}
	public Admin(String un, String pw, String em){
		super(un, pw, em, "");
		bossAdmin = false;
	}
	/**
	 * Upgrades a defUser into an admin.
	 * @param defUser
	 */
	public static Admin upgradeUser(User defUser){
		return new Admin(defUser.getUsername(), defUser.getPassword(), defUser.getEmail());
	}
	public static User deprecateAdmin( Admin adminToUser ){
	  return new User( adminToUser.getUsername(), adminToUser.getPassword(),
	                   adminToUser.getEmail(), "" );
	}
	public String toString(){
	    return super.toString();
	}
	
  public static boolean selfTest(){
    boolean passAll = true;
    Admin testAdmin = new Admin();
    
    testAdmin.setUsername("Bob");
    passAll = passAll & "Bob".equals(testAdmin.getUsername());
    
    testAdmin.setEmail("bob@gmail.com");
    passAll = passAll & "bob@gmail.com".equals(testAdmin.getEmail());
    
    testAdmin.changePassword("Bobs_password1");
    passAll = passAll & "Bob\'s password".equals(testAdmin.getPassword());
    
    System.out.println(testAdmin.toString());
    
    passAll = passAll & Admin.deprecateAdmin(testAdmin).isAdmin();
    
    return passAll;
  }
  public static void main(String[] args){
    selfTest();
  }
}